package KUtilities;

import java.awt.Dimension;

import javax.swing.BorderFactory;
import javax.swing.JDialog;
import javax.swing.JProgressBar;
import javax.swing.border.TitledBorder;

public class KProgressDialog extends JDialog implements Runnable
{
	private static final long serialVersionUID = 1L;
	String title;

	public KProgressDialog(String title)
	{
		super(KSwing.gui,true);
		this.title=title;
		new Thread(this).start();
	}
	
	public void run()
	{
		setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
		JProgressBar bar=new JProgressBar();
		bar.setIndeterminate(true);
		setUndecorated(true);
		bar.setBorder(BorderFactory.createTitledBorder(bar.getBorder(),title,TitledBorder.CENTER,TitledBorder.ABOVE_TOP));
		bar.setPreferredSize(new Dimension(bar.getPreferredSize().width+40,bar.getPreferredSize().height));
		add(bar);
		pack();
		KSwing.setCenterToComponent(this, KSwing.gui);
		setVisible(true);
	}
}
